#ifndef GX_GLTEXT_H
#define GX_GLTEXT_H

#include "Basic/GxLibBasic.h"
#include "Windows.h"
#include "wingdi.h"
#include "gl/gl.h"
#include "gl/glu.h"
#include "LibGL/OpenGL.h"

namespace GxRendering
{

	struct TextSize
	{
		int x,y;
	};

	class Font 
	{
	public:
		String FontName;
		int Size;
		bool Bold,Underline,Italic,StrikeOut;
		Font()
		{
			NONCLIENTMETRICS NonClientMetrics;
			NonClientMetrics.cbSize=sizeof(NONCLIENTMETRICS) - sizeof(NonClientMetrics.iPaddedBorderWidth);
			int rs = SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(NONCLIENTMETRICS),&NonClientMetrics,0);
			int err = GetLastError();
			FontName = NonClientMetrics.lfMessageFont.lfFaceName;
			Size = 9;
			Bold = false;
			Underline =false;
			Italic = false;
			StrikeOut= false;
		}
		Font(const String& sname, int ssize)
		{
			FontName = sname;
			Size = ssize;
			Bold = false;
			Underline =false;
			Italic = false;
			StrikeOut= false;
		}
		Font(const String & sname, int ssize, bool sBold, bool sItalic, bool sUnderline)
		{
			FontName = sname;
			Size = ssize;
			Bold = sBold;
			Underline =sUnderline;
			Italic = sItalic;
			StrikeOut= false;
		}
	};

	class Canvas
	{
	private:
		HFONT hdFont;
		HBRUSH hdBrush;
	public:
		HDC Handle;
		Canvas(HDC DC);
		~Canvas();
		void ChangeFont(Font newFont);
		void TextOut(const String & text, int X, int Y);
		int DrawText(const String & text, int X, int Y, int W);
		TextSize GetTextSize(const String& Text);
		void Clear(int w, int h);
	};

	class DIBImage
	{
	private:
		void CreateBMP(int Width, int Height);
	public:
		HDC Handle;
		HBITMAP bitHandle;
		Canvas * canvas;
		unsigned char** ScanLine;
		DIBImage();
		~DIBImage();
		void SetSize(int Width, int Height);	
	};

	class GLText
	{
	private:
		int TexHeight,TexWidth;
		GLuint TexID;
		DIBImage *Bit;
		
	public:
		GLText();
		~GLText();
		bool MultiLine;
		int TextHeight,TextWidth;
		void SetFont(Font Font); // Set the font styled of this label.
		void SetText(const String & Text, int w=0); // Set the text that is going to be displayed.
		void Draw(int X, int Y); // Draw the text at specified position
		TextSize GetTextSize(const String & text);
	};

	void BeginUIDrawing();
	void EndUIDrawing();

}

#endif